package com.changgou.entity.handler;

import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import com.changgou.entity.exception.Business40Exception;
import com.changgou.entity.exception.EResultCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by 柱子 on 2020/10/16 14:15   AOP异常处理
 */
@ControllerAdvice
public class ExceptionHandler40 {



    //系统异常处理
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result ExceptionHandler(Exception e) {
        e.printStackTrace();
        return new Result(false, StatusCode.ERROR, "请联系管理员或者刷新页面后重试");
    }


    //品牌异常处理
    @ExceptionHandler(value = Business40Exception.class)
    @ResponseBody
    public Result BaseExceptionHandler40(Business40Exception e) {
        EResultCode eResultCode = e.geteResultCode();
        return new Result(eResultCode);

    }

}
